#include "gtest/gtest.h"
#include "task_queue.h"

TEST(task_queue, put) {
    simpleThread::TaskQueue taskQueue;
    ASSERT_EQ(0, taskQueue.size());

    taskQueue.push([]{std::cout << "task_queue_test.put" << std::endl;});
    taskQueue.push([] {});
    ASSERT_EQ(2, taskQueue.size());

    auto get_call = taskQueue.pull();
    get_call();
    ASSERT_EQ(1, taskQueue.size());
}

TEST(task_queue, get) {
    simpleThread::TaskQueue taskQueue;
    auto put_run = [] {};
    taskQueue.push(put_run);
    auto get_run = taskQueue.pull();
    ASSERT_EQ(0, taskQueue.size());
}

TEST(task_queue, reset) {
    simpleThread::TaskQueue taskQueue;
    taskQueue.push([] {});
    ASSERT_EQ(1, taskQueue.size());
    taskQueue.reset();
    ASSERT_EQ(0, taskQueue.size());
}

TEST(task_queue, setClose) {
    simpleThread::TaskQueue taskQueue;
    taskQueue.push([] {});
    ASSERT_EQ(1, taskQueue.size());

    taskQueue.close();
    taskQueue.push([] {});
    ASSERT_EQ(1, taskQueue.size());
}